<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<script type="text/javascript" src="../js/jquery-3.3.1.js"></script>
<body>
  	<form action="freeCar.jsp" method="post">
   		<input type="text" id="blgUserId" hidden="hidden" value="${user.userId}"/><br/>
    	车牌号码<input type="text" id="license" /><br/>
    	汽车类型<input type="text" id="cartype" /><br/>
    	汽车颜色<input type="text" id="carColor"/><br/>
    	<input id="add" type="submit" value="登记"/>
   	</form>
</body>
	<script type="text/javascript">
		$(function(){
			$('#add').click(function(){
				$.ajax({
					url:'../freecar/addfreecar',
					method:'get',
					contentType:'application/json',
					dataType:'json',
					data:{
						'blgUserId':$('#blgUserId').val(),
						'license':$('#license').val(),
						'cartype':$('#cartype').val(),
						'carColor':$('#carColor').val()
					},
					success:function(data){	
						console.log(data);
					}
				})
			});
		})
	</script>
</html>